#define  _CRT_SECURE_NO_WARNINGS
#include<math.h>
int BTMaxDeepth(struct TreeNode* root)
{
	if (root == NULL)
	{
		return 0;
	}
	int high1 = 0;
	int high2 = 0;
	high1 = BTMaxDeepth(root->right);
	high2 = BTMaxDeepth(root->left);
	if (high1 == -1 || high2 == -1 || abs(high1 - high2) > 1)
	{
		return -1;
	}
	else
	{
		return high1 > high2 ? (high1 + 1) : (high2 + 1);
	}

}

bool isBalanced(struct TreeNode* root) {
	return BTMaxDeepth(root) >= 0;
}